473,425 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

GZip output compression with AJAX

Hi. To make page downloading quicker, I added GZipStream into the
Response filter. My (shortened VB) code snippet from Global.asax looks
like this:
............................................

Sub Application_BeginRequest(...)

If Request.RawUrl.Contains(".aspx") And _
Not Request.Headers("Accept-Encoding") Is Nothing Then

If Request.Headers("Accept-
encoding").ToLower().Contains("gzip") Then

Response.Filter = New GZipStream(Response.Filter,
CompressionMode.Compress, True)
Response.AppendHeader("Content-encoding", "gzip")

' Else...try deflate

End If

End If

End Sub
............................................

I added the check for .aspx in the request because it was messing up
images. Now that I'm using AJAX, it's giving me problems again. When
AJAX (I mean ASP's AJAX thing, but I'm not using Atlas) tries to
communicate with the server, it (JS) alert()s me that it could not
parse the server's response, and is probably because of a filter
(meaning this simple GZip stream).

How can I more efficiently check whether or not it is appropriate to
compress the output? And, by the way, is there a better way of
compressing output that won't mess up with images and could possibly
compress AJAX also?

-Mike PII

Jun 4 '07 #1
4 18709
Did you ever find a solution to this? I am having the same problem. If I
enable compression on our ISA server, it works fine. Just when using an
HTTPModule is when I have this problem. Very frustrating.

"Mike P2" wrote:
Hi. To make page downloading quicker, I added GZipStream into the
Response filter. My (shortened VB) code snippet from Global.asax looks
like this:
............................................

Sub Application_BeginRequest(...)

If Request.RawUrl.Contains(".aspx") And _
Not Request.Headers("Accept-Encoding") Is Nothing Then

If Request.Headers("Accept-
encoding").ToLower().Contains("gzip") Then

Response.Filter = New GZipStream(Response.Filter,
CompressionMode.Compress, True)
Response.AppendHeader("Content-encoding", "gzip")

' Else...try deflate

End If

End If

End Sub
............................................

I added the check for .aspx in the request because it was messing up
images. Now that I'm using AJAX, it's giving me problems again. When
AJAX (I mean ASP's AJAX thing, but I'm not using Atlas) tries to
communicate with the server, it (JS) alert()s me that it could not
parse the server's response, and is probably because of a filter
(meaning this simple GZip stream).

How can I more efficiently check whether or not it is appropriate to
compress the output? And, by the way, is there a better way of
compressing output that won't mess up with images and could possibly
compress AJAX also?

-Mike PII

Jun 6 '07 #2
On Jun 6, 8:50 am, bikemike <bikem...@discussions.microsoft.com>
wrote:
Did you ever find a solution to this? I am having the same problem. If I
enable compression on our ISA server, it works fine. Just when using an
HTTPModule is when I have this problem. Very frustrating.
No, I haven't found a solution yet. This is frustrating me too. GZip
compression is a pretty common thing, I'm sure it's been done
successfully in ASP.net and there are people in this newsgroup who
have the solution.

-Mike PII

Jun 6 '07 #3
Ok, I tried using

If Request.Headers("Accept").Contains("html") Or
Request.Headers("Accept").Contains("xml")) Then

instead to decide whether or not to compress the output with GZ and my
other filter that takes out some whitespace, but that's not helping
either. I guess ASP.net AJAX is served by the same page it's on
instead of ScriptResource.axd or whatever. So what can I do?

-Mike PII

Jun 11 '07 #4
I did find a solution to this problem that is not resolved with GZip in .NET,
but in IIS. Basically all I did was enable compression for only my virtual
directory in IIS. For whatever reason, the AJAX code does not have any
problems with this and it works great. I am getting nearly 90% compression
on my returned code now. After spending a day trying to make the .NET
solution work, I gave up and looked for alternative solutions. Fortunately,
the built-in IIS compression did the trick. If you need help on how to
enable it for just a single web or virtual, let me know.

"Mike P2" wrote:
Ok, I tried using

If Request.Headers("Accept").Contains("html") Or
Request.Headers("Accept").Contains("xml")) Then

instead to decide whether or not to compress the output with GZ and my
other filter that takes out some whitespace, but that's not helping
either. I guess ASP.net AJAX is served by the same page it's on
instead of ScriptResource.axd or whatever. So what can I do?

-Mike PII

Jun 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Xah Lee | last post by:
today i need to use Python to decompress gzip files. since i'm familiar with Python doc and have 10 years of computing experience with 4 years in unix admin and perl, i have quickly located the...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi Does anyone have experience using gZip compression on the IIS server with a ASP.NET application. How much can a page be compressed. As i see it it must have a huge impact on the total size....
2
by: .nLL | last post by:
hi. i have recently enabled gzip compression on my server and it works fine. but i have noticed something wierd. To protect my self from hotlinking i use a simple code to send my download with...
2
by: Chaos | last post by:
I have tried to search Google, but I cannot seem to find a library to decompress a gzip string or char to a string or char. I want to write something that allows libcurl to access a page, save the...
4
by: mathieu | last post by:
Hello, Browsing the archive of this group I see that the c++ iostream wrapper that are shipped with zlib are not satisfying : ...
2
by: Carlo Razzeto | last post by:
Hello there, I'm having an odd issue with GZIP compression (having followed example code found on MSDN). Basically, after running through the compression routine I end up with a byte array...
3
by: Sean Davis | last post by:
I have a set of numpy arrays which I would like to save to a gzip file. Here is an example without gzip: b=numpy.ones(1000000,dtype=numpy.uint8) a=numpy.zeros(1000000,dtype=numpy.uint8) fd =...
6
by: Giorgio Parmeggiani | last post by:
Hi I'm using the gzip compression found in WCG samples kit. It works well, but how can I set the SendTimeout and ReceiveTimeout parameters? Thank in advance Giorgio
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.